

<?php
//装载模板文件
include_once("function/tpl.php");

//获取微信发送数据
$mysql = new SaeMysql();
$postStr = $GLOBALS["HTTP_RAW_POST_DATA"];

$mc = memcache_init();

//返回回复数据
if (!empty($postStr))
{

    //解析数据
    $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
    //发送消息方ID
    $fromUsername = $postObj->FromUserName;
    //接收消息方ID
    $toUsername = $postObj->ToUserName;
    //消息类型
    $form_MsgType = $postObj->MsgType;
     
    //事件消息
    if ($form_MsgType == "event") 
   {
        //获取事件类型
        $form_Event = $postObj->Event;
        //订阅事件
        if ($form_Event == "subscribe") 
            //回复欢迎文字消息
      include_once("function/Menu.php");
    }
    
    
    include_once("function/PowerCheck.php");
    
    $address_book=$connect;
    $power=$connect['power'];

    
    
    //图片消息
    if ($form_MsgType == "image") 
    {
        include_once("function/Image.php");
    }

    if ($form_MsgType == "text")
    {
        $form_Content = trim($postObj->Content);
        if ($form_Content == "菜单") //菜单
            include_once("function/Menu.php");
        if (($form_Content == "相册") || (($mc->get($fromUsername . "_do") == "相册") && is_numeric($form_Content)) || (($mc->get($fromUsername . "_do") == "相册"))&&(($form_Content == "n") || ($form_Content == "N")))//查图片
            include_once("function/Found.php");
        if (($form_Content == "通知") || ($mc->get($fromUsername . "_do") == "通知")&&(($form_Content == "n") || ($form_Content == "N")))//通知
            include_once("function/Notice.php");
        if(($form_Content == "留言"||$mc->get($fromUsername . "_do") == "留言"))//留言
            include_once("function/Message.php");
        
        if(($form_Content =="电话"||$mc->get($fromUsername . "_do") == "电话"))//通讯录
            include_once("function/AddressBook.php");
        if((($form_Content) =="快递"||$mc->get($fromUsername . "_do") == "快递"))//快递查询
            include_once("function/Express.php");
        if($form_Content == "音乐")//音乐盒子
            include_once("function/Mbox.php"); 
        if($form_Content == "天气")//天气
            include_once("function/weather.php");
        if((($form_Content =="鸡鸡"||$mc->get($fromUsername . "_do") == "鸡鸡")))//simsimi机器人
            include("function/simsimi.php");
        if ($form_Content == "应用")
            include("function/BaiduApp.php");
         if ($form_Content == "搜书"||$mc->get($fromUsername . "_do") == "搜书")
            include("function/library.php");
          if ($form_Content == "课室"||$mc->get($postObj->FromUserName . "_do") == "课室")          
            include("function/classroom.php");
        if ($form_Content == "关于")
            include_once("function/about.php"); 
    
     
	else
            include_once("ErrorMessage/Function_Not_Opened.php");
        
    } 
   else 
   {
            include_once("ErrorMessage/Function_Not_Opened.php");
   }
}
?>